package geektime.spring.springbucks.controller;

import geektime.spring.springbucks.model.Coffee;
import geektime.spring.springbucks.service.CoffeeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("coffee")
public class CoffeeController {

    @Resource
    private CoffeeService coffeeService;

    /**
     * 返回json数据格式
     * @return
     */
    @GetMapping(value = "findAllToJson",produces = "application/json; charset=utf-8")
    public List<Coffee> findAllToJson(){
        return coffeeService.findAll();
    }

    /**
     * 返回xml数据格式
     * @return
     */
    @GetMapping(value = "findAllToXml",produces = "application/xml; charset=utf-8")
    public List<Coffee> findAllToXml(){
        return coffeeService.findAll();
    }
}
